<?php
/**
 * (commands) 客诉反馈报表（品质报告）
 */
namespace App\Console\Commands\Quality;

use App\Logic\Quality\Report;
use App\Logic\Quality\ReportC;
use Illuminate\Console\Command;
class QualityReport extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'quality:report {date}';

    /**
     * The console command description.
     * @var string
     */
    protected $description = 'quality report';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    private $_model = ['Report' => Report::class,'ReportC' => ReportC::class];

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $date = $this->argument('date');
        if($date){
            $model = $this->choice('choice exe model: ', ['Report', 'ReportC']);
            if($model){
                $class = $this->_model[$model];
                $class::init($date);
                $this->info($model.' 统计完成!');
            }else{
                $this->error('ERROR: 请选择MODEL!');
            }
        }else{
            $this->error('请提供统计日期!');
        }
        die('finish');
    }
}
